package com.whfc.iot.fse;

import com.whfc.iot.server.IotServer;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.Resource;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Description:
 * @author: xugcheng
 * @version: 1.0
 * @date: 2021-05-19 10:35
 */
@SpringBootApplication(scanBasePackages = "com.whfc")
public class IotFseApplication implements CommandLineRunner {

    public static int TW_PORT = 8160;

    public static int LIFT_PORT = 8170;

    @Resource(name = "twServer")
    private IotServer twServer;

    @Resource(name = "liftServer")
    private IotServer liftServer;

    public static void main(String[] args) {
        SpringApplication.run(IotFseApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {

        ExecutorService executorService = Executors.newFixedThreadPool(2);
        executorService.execute(() -> {
            twServer.port(TW_PORT);
            twServer.run();
        });
        executorService.execute(() -> {
            liftServer.port(LIFT_PORT);
            liftServer.run();
        });
    }
}
